/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @Original Author: jin Chen
 * @date: Nov 29, 2004$
 * @version: 1.0
 */
package edu.psu.geovista.app.visualclassifier.classify.v2.colorpalette.v2;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

public class CustomizeFixedSwatchPaneImpl extends FixedSwatchPaneImpl{
    public CustomizeFixedSwatchPaneImpl(int width, int height, int[][] colorvalues) {
        super(width, height, colorvalues);
    }

    public CustomizeFixedSwatchPaneImpl(int width, int height, Color[][] colors) {
        super(width, height, colors);
    }

    public void mouseClicked(MouseEvent e){
        int clickCount = e.getClickCount();
        if(clickCount==1) {
            super.mouseClicked(e);
        }
        else if (clickCount==2) {
            JLabel label=(JLabel) e.getSource();
             Color bgcolor = label.getBackground();
             System.out.println(" click on swatch:"+bgcolor);
            Color newcolor = JColorChooser.showDialog(this,"Please choose a color", bgcolor);///colorchs=new
            label.setBackground(newcolor);
            this.firePropertyChange(SELECT_COLOR,null,newcolor);
        }

    }

  
    private static FixedSwatchPaneImpl testCustomColors(){
        Color color=new Color(192,192,192);
        Color[][] mycolors= new Color[3][4];
        for (int i=0;i<mycolors.length ;i++){
            for (int j=0;j<mycolors[i].length ;j++){
                mycolors[i][j]=color;
            }
        }
        FixedSwatchPaneImpl sp=new CustomizeFixedSwatchPaneImpl(30,30,mycolors);
        return sp;
    }
}
